var popup = 0;
var clientWidth;
var clientHeight;

$(document).ready(

		function() {
			
		//givemeRank(); //랭킹 갖고와서 홈에 뿌려준다
		
		clientWidth = parseInt($(window).width()); //핸드폰의 가로사이즈를 구한다
		clientHeight = parseInt($(window).height()); //세로
		
		//givemeRank();
		
	     $("#bodyy").css({  //선택된 이미지에 CSS를 변경한다 2번방법
			"width"  : clientWidth,
			"height" : clientHeight
		 }); 
	     
	     $("#info").css({  //선택된 이미지에 CSS를 변경한다 2번방법
				"width"  : clientWidth*0.8,
				"height" : clientHeight*0.8,
				"top" : clientHeight*0.1
	     }); 
	     
	     $("#start").css({  //선택된 이미지에 CSS를 변경한다 2번방법
				"width"  : clientWidth*0.21,
				"height" : clientHeight*0.12,
				"top" : clientHeight*0.65,
				"left" : clientWidth*0.4
	     }); 
	     
	     $("#howto").css({  //선택된 이미지에 CSS를 변경한다 2번방법
				"width"  : clientWidth*0.21,
				"height" : clientHeight*0.12,
				"top" : clientHeight*0.8,
				"left" : clientWidth*0.4
	     }); 
		     

		
});


function gameStart(){
	
	//location.href="./jsp/stage.html";
	location.href="./jsp/login.jsp";
	
}

function howtoPlay(){
	
	  if(popup==0)  {
          
          document.getElementById("info").style.visibility="visible";
          popup = 1;
          
      }
	
}

function popclose(){
	
  if(popup==1)  {
          
	  	  document.getElementById("info").style.visibility="hidden";
          popup = 0;
          
      }
	
}

function givemeRank(){ //랭킹을 받아오자
	
	$.ajax ({
		type: "post"
		, url: "./ScoreServlet"
		, contentType:"application/x-www-form-urlencoded; charset=UTF-8"
		, dataType:'jsonp'
		, jsonp:'callback'
		, data: "kind=ranking"
		, success: function (response, status, result) {
			
			var plist = eval(response);
			var content = '<tr><td class="list-title"><span class="list-section" >Rank</span></td><td class="list-title"><span class="list-section" >Name</span></td><td class="list-title"><span class="list-section" >Score</span></td></tr>';
			for(var i=0; i<plist.length;i++){
				content+='<tr><td class="list-title"><span class="list-section" >'+eval(i+1)+'</span></td><td class="list-title"><span class="list-section" >'+plist[i].username+'</span></td><td class="list-title"><span class="list-section" >'+plist[i].score+'</span></td></tr>';
			}
			
			$("#table_ranking").html(content);
		}
		, error : function(request, status, error) {
			//통신 에러 발생시 처리
			alert("code : " + request.status + "\r\nmessage : " + request.reponseText);
		}
	});
	/*$.ajax ({
		type: "post"
		, url: "../PresentingServlet"
		, contentType:"application/x-www-form-urlencoded; charset=UTF-8"
		, dataType:'jsonp'
		, jsonp:'callback'
		, data: "kind=get_info&code="+entered_code
		, success: function (response, status, result) {
			
			var tmp = eval(response);
			
			var userid = tmp.userid;
			var code = tmp.code;
			var pre_title = tmp.title;
			var hostname = tmp.hostname;
			var slidenum = tmp.slide_num;	
			
			$('#list_view li').not('#list_divider').remove();
			$("#list_view").append('<li data-theme="a"><a href="#" data-icon="search"><h1>'+pre_title+'</h1><p>'+hostname+'</p></a></li>');
			$("#list_view").listview('refresh'); 
			//ppt 다운이 다 안받아져있으면? 
			//location.href="./jsp/show_audience.jsp?userid="+userid+"&code="+code+"&pre_title="+pre_title+"&hostname="+hostname+"&slidenum="+slidenum;					
		}
		, error : function(request, status, error) {
			//통신 에러 발생시 처리
			alert("code : " + request.status + "\r\nmessage : " + request.reponseText);
		}
	});*/
	
	
	
}





jquery = function()
{
	$("#start").live('focus',function(){

		document.getElementById('start').src="resource/icon/fbtn1.png";
    });
	$("#howto").live('focus',function(){
			
        document.getElementById('howto').src="resource/icon/fbtn2.png";
	});
	
	$("#start").live('focusout',function(){
		document.getElementById('start').src="resource/icon/btn1.png";
	});
	
	$("#howto").live('focusout',function(){
	
		document.getElementById('howto').src="resource/icon/btn2.png";
	});
	
 }